package com.yjhb.android.sbz.entity;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2020/12/7 15:36
 */
public class ResultSet<T> {
    private final String TAG = "ResultSet";

    /**
     * records : []
     * total : 13
     * size : 15
     * current : 1
     * orders : []
     * optimizeCountSql : true
     * isSearchCount : true
     * searchCount : true
     * pages : 1
     */

    private int total;
    private int size;
    private int current;
    private boolean optimizeCountSql;
    private boolean isSearchCount;
    private boolean searchCount;
    private int pages;
    private List<T> records;
    private List<T> orders;

    public static ResultSet objectFromData(String str) {

        return new Gson().fromJson(str, ResultSet.class);
    }

    public static ResultSet objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), ResultSet.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public boolean isOptimizeCountSql() {
        return optimizeCountSql;
    }

    public void setOptimizeCountSql(boolean optimizeCountSql) {
        this.optimizeCountSql = optimizeCountSql;
    }

    public boolean isIsSearchCount() {
        return isSearchCount;
    }

    public void setIsSearchCount(boolean isSearchCount) {
        this.isSearchCount = isSearchCount;
    }

    public boolean isSearchCount() {
        return searchCount;
    }

    public void setSearchCount(boolean searchCount) {
        this.searchCount = searchCount;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public List<T> getOrders() {
        return orders;
    }

    public void setOrders(List<T> orders) {
        this.orders = orders;
    }
}
